#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll N = 2e5+5;

void solve(){
    ll n;
    cin >> n;

    ll mx = 0;
    vector<ll> a(n);
    vector<ll> cnt(N, 0);
    for(int i = 0; i < n; i++){
    	cin >> a[i];
    	cnt[a[i]]++;
    	mx = max(mx, a[i]);
    }

    ll res = 0;
    for(ll i = mx; i >= 1; i--){
    	if(cnt[i] >= 2){
    		res += (cnt[i] * (cnt[i] - 1) / 2) * (n - cnt[i]);
    	}
    }

    cout << res << '\n';
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}